package com.tanhua.controller;

import com.tanhua.model.domain.WenJuan;
import com.tanhua.model.domain.WenJuanList;
import com.tanhua.model.mongo.Report;
import com.tanhua.model.mongo.TestList;
import com.tanhua.server.impl.TestSoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/testSoul")
public class TestSoulController {
    @Autowired
    TestSoulService testSoulService;

    //获取试卷列表
    @GetMapping
    public ResponseEntity getAll() {
        List<TestList> TestList = testSoulService.getAll();
        return ResponseEntity.ok(TestList);
    }

    //提交问卷
    @PostMapping()
    public ResponseEntity sendQuestion(@RequestBody WenJuanList wenJuanList) {
        List<WenJuan> wenjuan = wenJuanList.getAnswers();
        WenJuan wenJuan = wenjuan.get(0);
        String optionId = wenJuan.getOptionId();
        String questionId = wenJuan.getQuestionId();
        return ResponseEntity.ok("6");
    }

    //查看结果
    @GetMapping("/report/{id}")
    public ResponseEntity lookReport(@PathVariable("id") String id) {
        Report report = testSoulService.lookReport(id);
        return ResponseEntity.ok(report);
    }
}
